package com.zzq.my.jetpacks.jectpackapp.net.loadindexdata

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.aisier.architecture.base.BaseViewModel
import com.aisier.network.observer.StateLiveData
import com.zzq.my.jetpacks.jectpackapp.bean.LoadIndexInfo
import com.zzq.my.jetpacks.net.rxhttp.show
import kotlinx.coroutines.launch

/**
 * 描述：class describe
 * 作者：zhuangzeqin
 * 时间: 2021/11/25-16:21
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class LoadIndexDataViewModel: BaseViewModel() {
    private val mRepository by lazy {
        LoadIndexDataRepo()
    }
    val LoadIndexDataLiveData = StateLiveData<LoadIndexInfo?>()
    val LoadIndexDataLiveData2 = MutableLiveData<LoadIndexInfo>()

    fun reqLoadIndexData() {
        //启动一个协程
        viewModelScope.launch {
            LoadIndexDataLiveData.value =  mRepository.reqLoadIndexData()
        }
    }

//    fun reqLoadIndexDataRxHttp() {
//        viewModelScope.launch {
//            mRepository.reqLoadIndexDataRxHttp().apply {
//                onSuccess {
//                    LoadIndexDataLiveData2.value = it
//                }
//                onFailure {
//                    it.show()
//                }
//            }
//        }
//    }
}